<template>
	<div class="model">
		<h2 class="model__title">
			选择区域经理
			<span @click="close" class="model__title--close">&times;</span>
		</h2>
		<div class="model__content" v-loading="loading">
			<el-form ref="form" :model="form" label-width="120px">
				<el-form-item label="选择区域经理">
					<el-select v-model="sale_man_id" placeholder="请选择区域经理">
  						<el-option v-for="(item, index) in managerList" :key=index :label="item.real_name + item.mobile" :value="item.sale_man_id"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="check_submit">
						<span>提交</span>
					</el-button>
				</el-form-item>
			</el-form>
		</div>
	</div>
</template>

<script>
	export default {
		created(){
			this.loadData();
		},
		props: ["id"],
		data() {
			return {
				loading: true,
				sale_man_id: null,
				managerList: []
			}
		},
		methods: {
			close() {
				this.$parent.showCheckModel = false;
			},
			loadData() {
				this.loading = true;
				var url = `${this.url}/spread/spread_get_manager_list.action`;
				var params = {
				};
				this.$http.get(url,{ params }).then((res)=> {
					this.loading = false;
					this.managerList = res.data.result.rows;
				});
			},
			check_submit() {
				if(!this.sale_man_id) {
					this.$message({
						type: "error",
						message: '请选择区域经理'
					});
					return;
				}
				this.$parent.okAgree(this.id, this.sale_man_id);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.model {
		width: 400px;
		left: calc(50% - 200px);
		height: 300px;
		top: 100px;
	}
</style>